package com.fun_ordering.controller;

/**
 * @author 陈星
 * @date 2024/3/24 20:00
 */

import com.fun_ordering.pojo.FoEmployee;
import com.fun_ordering.util.JJwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 所有controller的父类
 */
@RestController
public class BaseController {
    @Autowired
    private HttpServletRequest request;
    //获取token
    public FoEmployee decodeToken(String token){
        return JJwtUtil.decode(token);
    }
    //获取前端登录用户名的显示
    public FoEmployee getUser(){
        String token = request.getHeader("Token");
        FoEmployee decode = JJwtUtil.decode(token);
        return decode;
    }
}
